<?php
/** 轮播图 */
namespace app\api\controller\v1;

use app\api\validate\IDMustBePositiveInt;
use app\api\model\Banner as BannerModel;
use app\lib\exception\BannerMissException;

class Banner{
    /**
     * 获取指定id的banner信息
     * @url /banner/:id
     * @http GET
     * @id banner的id号
     */
    public function getBanner($id){
        //验证
        (new IDMustBePositiveInt())->goCheck();
        //通过id号获取banner对象
        $banner=BannerModel::getBannerByID($id);
        if(!$banner){//判断
            throw new BannerMissException();//返回异常
        }
        return $banner;//返回对象
    }
}